<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp" %>
<!DOCTYPE>
<html>
  <head>
    <base href="<%=basePath %>">
    <title>${pagePanel.comments }</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<%@include file="/views/global/include.jsp" %>
	<c:forEach var="item" items="${cssUrlList }">
		<link rel="stylesheet" type="text/css" href="${item }" />
	</c:forEach>
  </head>
  
  <body>
  	<%@include file="/views/global/top.jsp" %>
  	<div class="alert alert-success">
	  	<div class="main-md">直接点击下面内容中的链接进行编辑</div>
 	</div>
 	<div id="_pagePanelContent" contentEditable="true">
		${entity.content }
	</div>
	<form id="submitForm">
		<input type="hidden" name="id" value="${entity.id }"/>
		<input type="hidden" name="pageKey" value="${entity.pageKey }"/>
	</form>
 	<%@include file="/views/global/AdminScripts.jsp" %>
  </body>
<script type="text/javascript">
$(document).ready(function(){
	$("A", "#_pagePanelContent").click(function(){
		var _this = this;
		var detailId = $(_this).attr("detailId");
		//window.open("admin/pageEdit/detail?pageKey=${entity.pageKey}&detailId="+(null==detailId?0:detailId));
		art.dialog.data("result", "false");
		art.dialog.data("title", $(_this).html());
		art.dialog.open("admin/pageEdit/detail?pageKey=${entity.pageKey}&detailId="+detailId, {
			close: function(){
				if("true" == art.dialog.data("result")){
					var dtId = art.dialog.data("detailId");
					$(_this).attr("detailId", dtId);
					savePanel();
				}
			}, title: $(_this).html(), width: 1000
		}, false);
		return false;
	});
});

function savePanel(){
	$("#submitForm").goAjax({semantic: false, checkLogin: true,
		url: "admin/pageEdit/save",
		data:{content: $("#_pagePanelContent").html()},
		success: function(jsonData) {
			if(true == jsonData.success){
   				window.location.reload();
   			} else {
   				$.error(jsonData.message);
   			}
		}
	});
}
</script>
</html>
